package com.parleys.helper;

import java.util.List;

import android.app.ProgressDialog;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.parleys.adapter.ParleysListAdapter;
import com.parleys.domain.ParleysListObject;

public class ProcessResultListRunnable implements Runnable {

	private final List<? extends ParleysListObject> list;
	private final ListView listView;
	private final TextView emptyText;
	private final ParleysListAdapter parleysListAdapter;
	private final ProgressDialog progressDialog;

	public ProcessResultListRunnable(final List<? extends ParleysListObject> list, final ListView listView,
			final TextView emptyText, final ParleysListAdapter parleysListAdapter, final ProgressDialog progressDialog) {
		this.list = list;
		this.listView = listView;
		this.emptyText = emptyText;
		this.parleysListAdapter = parleysListAdapter;
		this.progressDialog = progressDialog;
	}

	@Override
	public void run() {
		if (list.isEmpty()) {
			listView.setVisibility(View.GONE);
			emptyText.setVisibility(View.VISIBLE);
		} else {
			listView.setAdapter(parleysListAdapter);
			listView.setVisibility(View.VISIBLE);
			emptyText.setVisibility(View.GONE);
		}
		progressDialog.dismiss();
	}
}
